<template>
  <div class="bg-[#232324] h-[100%]">
    <el-collapse v-loading="loading" v-model="activeNames">
      <el-form label-width="100" :model="states" size="default">
        <el-collapse-item
          :title="`仪表盘`"
          :name="i + 1 + 'gauge'"
          v-for="(item, i) in states"
          :key="item.name + i + 'a'"
        >
          <el-form-item label="仪表盘半径">
            <el-input v-model="item.radius" />
          </el-form-item>
          <el-form-item label="进度条宽度">
            <el-input-number v-model="item.progress.width" />
          </el-form-item>
          <el-form-item label="背景条宽度">
            <el-input-number v-model="item.axisLine.lineStyle.width" />
          </el-form-item>
          <el-form-item label="是否显示标题">
            <el-switch v-model="item.title.show" />
          </el-form-item>
          <el-form-item label="标题颜色">
            <el-color-picker v-model="item.title.color" />
          </el-form-item>
          <el-form-item label="标题大小">
            <el-input-number v-model="item.title.fontSize" />
          </el-form-item>
          <el-form-item label="水平偏移">
            <el-input v-model="item.title.offsetCenter[0]" />
          </el-form-item>
          <el-form-item label="垂直偏移">
            <el-input v-model="item.title.offsetCenter[1]" />
          </el-form-item>

          <el-form-item label="是否显示详情">
            <el-switch v-model="item.detail.show" />
          </el-form-item>
          <el-form-item label="详情文字颜色">
            <el-color-picker v-model="item.detail.color" />
          </el-form-item>
          <el-form-item label="详情文字大小">
            <el-input-number v-model="item.detail.fontSize" />
          </el-form-item>
          <el-form-item label="水平偏移">
            <el-input v-model="item.detail.offsetCenter[0]" />
          </el-form-item>
          <el-form-item label="垂直偏移">
            <el-input v-model="item.detail.offsetCenter[1]" />
          </el-form-item>
          <el-form-item label="详情宽度">
            <el-input-number v-model="item.detail.width" />
          </el-form-item>
          <el-form-item label="详情高度">
            <el-input-number v-model="item.detail.height" />
          </el-form-item>
          <el-form-item label="自定义详情">
            <el-input v-model="item.detail.formatter" />
          </el-form-item>

          <el-form-item label="是否显示指针">
            <el-switch v-model="item.pointer.show" />
          </el-form-item>

          <el-form-item label="指针宽度">
            <el-input v-model="item.pointer.width" />
          </el-form-item>
          <el-form-item label="指针长度">
            <el-input v-model="item.pointer.length" />
          </el-form-item>
          <el-form-item label="水平偏移">
            <el-input v-model="item.pointer.offsetCenter[0]" />
          </el-form-item>
          <el-form-item label="垂直偏移">
            <el-input v-model="item.pointer.offsetCenter[1]" />
          </el-form-item>
          <el-form-item label="指针颜色">
            <el-color-picker v-model="item.pointer.itemStyle.color" />
          </el-form-item>
          <el-form-item label="指针描边颜色">
            <el-color-picker v-model="item.pointer.itemStyle.borderColor" />
          </el-form-item>
          <el-form-item label="指针描边宽度">
            <el-input-number v-model="item.pointer.itemStyle.borderWidth" />
          </el-form-item>
        </el-collapse-item>
      </el-form>
    </el-collapse>
  </div>
</template>

<script setup>
import { onMounted, watch, ref, reactive, computed } from "vue";
const loading = ref(true);
const activeNames = ref();
const props = defineProps({
  models: {
    type: Object,
    default: () => ({}),
  },
});
const emit = defineEmits(["update:models", "edit"]);
let states = ref(null);
onMounted(() => {
  states.value = JSON.parse(JSON.stringify(props.models.series));

  setTimeout(() => {
    loading.value = false;
  }, 200);
});

watch(
  () => states.value,
  (val) => {
    emit("update:models", { ...props.models, series: val });
  },
  {
    deep: true,
  }
);
</script>

<style scoped lang="scss">
:deep(.el-collapse-item__header) {
  padding-left: 10px !important;
}

:deep(.el-input) {
  width: 180px !important;
}
:deep(.el-select) {
  width: 180px !important;
}
</style>
